#! /usr/bin/python
# -*- coding: utf-8 -*-

#***********************************
# Data collect
#***********************************

import os
import sys
import time
from queue import *
import struct

import pickle
from kafka import *


import app_global
from app_global import *

#from plate_model import *
#from plate_syndata import *
from db_ctrl import *
from db_conf import *
from plc_helper import *

from daq_plc import *
from daq_shp import *

log = app_global.gLog

if __name__=="__main__":
    log.info("sys start")
    producer = KafkaProducer(bootstrap_servers=['0.0.0.0:9092'])
    
    daq_plc = CDAQPlc(producer);
    daq_shp = CDAQShp(producer);
    daq_plc.start()    
    daq_shp.start()    

    try:
        while True:
            time.sleep(ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        log.info("catch ctrl+c, interrupt app")
        app_global.SYS_RUN = False

    daq_plc.join()
    daq_shp.join()

    producer.close()
